package route

import (
	"chitchat_http/common"
	"chitchat_http/controller"
	"github.com/doujunyu/gogo/gogo"
	"github.com/doujunyu/gogo/job"
)

func Route(r *gogo.Centre) {
	//跨域
	r.Middleware = append(r.Middleware, common.CrossDomain)
	r.Middleware = append(r.Middleware, common.TokenInput)
	//用户--------------------------------------------------------------------------------------------------------------+
	//账号登录
	r.POST("/LoginByUsername", controller.LoginByUsername)
	//邮箱登录
	r.POST("/LoginByEmail", controller.LoginByEmail)
	//手机号登录
	r.POST("/LoginByMobile", controller.LoginByMobile)
	//账号注册
	r.POST("/RegisterByUsername", controller.RegisterByUsername)
	//个人中心
	r.GET("/MySelf", controller.CheckToken, controller.MySelf)
	//修改密码
	r.POST("/UserByChangePassword", controller.CheckToken, controller.UserByChangePassword)
	//首页
	r.GET("/Index", controller.Index)


	//发布动态
	r.POST("/BbsByRelease", controller.CheckToken, controller.BbsByRelease)
	//动态删除
	r.POST("/BbsByDelete", controller.CheckToken, controller.BbsByDelete)
	//动态点赞+1
	r.POST("/BbsByPraiseInc", controller.CheckToken, controller.BbsByPraiseInc)
	//动态点赞-1
	r.POST("/BbsByPraiseDec", controller.CheckToken, controller.BbsByPraiseDec)
	//评论回复
	r.POST("/BbsDiscussByReply", controller.CheckToken, controller.BbsDiscussByReply)
	//删除评论
	r.POST("/BbsDiscussByDelete", controller.CheckToken, controller.BbsDiscussByDelete)
	//动态评论点赞+1
	r.POST("/BbsDiscussByPraiseInc", controller.CheckToken, controller.BbsDiscussByPraiseInc)
	//动态评论点赞-1
	r.POST("/BbsDiscussByPraiseDec", controller.CheckToken, controller.BbsDiscussByPraiseDec)
	//动态列表
	r.GET("/BbsByList",controller.CheckToken,controller.BbsByList)
	//动态详情
	r.GET("/BbsByInfo",controller.CheckToken,controller.BbsByInfo)
	//动态一级列表
	//r.GET("/BbsDiscussByOneLevelList",controller.CheckToken,controller.BbsDiscussByOneLevelList)
	////动态二级级列表
	//r.GET("/BbsDiscussByTwoLevelList",controller.CheckToken,controller.BbsDiscussByTwoLevelList)
	//动态评论
	r.GET("/BbsDiscussByList",controller.CheckToken,controller.BbsDiscussByList)

	//申请加好友
	r.POST("/ChatByApplyFriendOrApplyGroup",controller.CheckToken,controller.ChatByApplyFriendOrApplyGroup)
	//申请列表
	r.GET("/ChatByApplyList",controller.CheckToken,controller.ChatByApplyList)
	//操作申请信息
	r.POST("/ChatByApplyCheck",controller.CheckToken,controller.ChatByApplyCheck)
	//好友列表
	r.GET("/ChatByFriendList",controller.CheckToken,controller.ChatByFriendList)
	//发送消息
	r.POST("/ChatBySendMessage",controller.CheckToken,controller.ChatBySendMessage)
	//创建群组
	r.POST("/ChatByCreateGroup",controller.CheckToken,controller.ChatByCreateGroup)
	//消除接收到得消息
	r.POST("/ChatByCleanMessage",controller.CheckToken,controller.ChatByCleanMessage)

	//总后台接口---------------------------------------------------------------------------------------------------------+
	//管理员登录
	//r.POST("/Admin/LoginByUsername", controller_admin.LoginByUsername)

	//公共接口-----------------------------------------------------------------------------------------------------------+

	//图片上传
	r.POST("/PictureUpLoading", common.ByPictureUpLoading)
	//文件下载
	r.GET("/download/", common.ByDownLoad)
	//访问public下面的文件
	r.GET("/static/", common.ByPublic)
	//服务器关闭接口
	r.POST("/configByOver", func(j *job.Job) {
		if j.Input["password"] == "init0" {
			r.ServerClose <- 1
			j.JsonSuccess(nil, "操作成功")
			return
		}
		j.JsonError(nil, "密码错误")
	})
	//默认接口
	r.GET("/", func(j *job.Job) {
		j.JsonError(nil, "接口不存在")
	})
	r.POST("/", func(j *job.Job) {
		j.JsonError(nil, "接口不存在")
	})
}
